import { createStore } from 'redux';

let defaultCity = '苏州'
try {
  if (localStorage.city) {
    defaultCity = localStorage.city
  }
}catch(e){}

// reducer
const reducer = (state = defaultCity, action)=>{
    switch(action.type){
        case 'SETCITY':
            try {
                localStorage.setItem('city',  action.city)
            } catch (e) {}
            return action.city;
        default:
            return state;
    }
}

const store = createStore(reducer);

export default store